<?php
/**
 * Created by PhpStorm.
 * User: jswei
 * Date: 2018/5/3
 * Time: 14:06
 */
namespace app\first\model;

use think\Model;

class UservipLog extends Model{
    protected $autoWriteTimestamp = true;

    /**
     * @param int $id
     * @param string $field
     * @return array|\PDOStatement|string|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getOneById($id = 0, $field = '*'){
        $info = $this
            ->field($field)
            ->with('member')
            ->where('id','eq',$id)
            ->find();
        return $info;
    }

    public function member(){
        return $this->hasOne('member','id','mid')
            ->bind([
                'account',
                'nickname',
                'avatar',
                'is_auth',
                'auth_time'
            ]);
    }
}